import request from '@/utils/request'
let baseUrl =
  process.env.NODE_ENV === 'production'
    ? 'api/reconciliation'
    : 'http://172.16.0.6:8024'
let itemBaseUrl =
  process.env.NODE_ENV === 'production' ? 'api/core' : 'http://172.16.0.14:8020'

/* ----------------对账列管理 start-------------------- */
export const getColumnList = (data: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/column/page',
    method: 'post',
    data
  })

export const addColumn = (data?: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/column/create',
    method: 'post',
    data
  })

export const getColumnDetail = (columnCode: string, data?: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/column/detail/' + columnCode,
    method: 'post',
    data
  })

export const updateColumn = (data?: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/column/update',
    method: 'post',
    data
  })

/* ----------------对账列管理 end-------------------- */

/* ----------------数据源配置 start-------------------- */
export const getDataSourceList = (data: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/datasource/page',
    method: 'post',
    data
  })

export const addDataSource = (data?: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/datasource/create',
    method: 'post',
    data
  })

export const getDataSourceDetail = (code: string, data?: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/datasource/detail/' + code,
    method: 'post',
    data
  })

export const updateDataSource = (data?: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/datasource/update',
    method: 'post',
    data
  })
/* ----------------数据源配置 end-------------------- */

/* ----------------对账记录 start-------------------- */
export const getTaskLogList = (data: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/task-log/page',
    method: 'post',
    data
  })

export const getTaskLogDetailList = (data: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/task-log-detail/page',
    method: 'post',
    data
  })

export const getDetailResultList = (data: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/task-log-detail-result/query',
    method: 'post',
    data
  })

export const taskListDownload = (data?: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/task-log-detail-result/export',
    method: 'post',
    responseType: 'blob',
    data
  })
/* ----------------对账记录 end-------------------- */

/* ----------------对账配置管理 start-------------------- */
export const getTaskList = (data: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/task/page',
    method: 'post',
    data
  })

export const getTaskDetail = (id: string, data?: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/task/detail/' + id,
    method: 'post',
    data
  })

export const addTask = (data?: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/task/create',
    method: 'post',
    data
  })

export const updateTask = (data?: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/task/update',
    method: 'post',
    data
  })

export const changeStatus = (data?: any) =>
  request({
    baseURL: baseUrl,
    url: '/admin/api/v1/recon/task/change-status',
    method: 'post',
    data
  })
/* ----------------对账配置管理 end-------------------- */

// 字典配置
export const getGroupList = (data: any) =>
  request({
    baseURL: itemBaseUrl,
    url: '/dictionary/list',
    method: 'post',
    data
  })
